home *** CD-ROM | disk | FTP | other *** search
- /**
- AEFX_FXwin.c
-
- Part of the Adobe After Effects 3.1 SDK
- Copyright (c)1993-96, Adobe Systems Inc, All Rights Reserved.
-
- FX window UI sample
-
- Revision History
- 1.0, created by dmw
- **/
-
- #include "AE_Effect.h"
- #include "AE_EffectCB.h"
- #include "AE_EffectUI.h"
- #include "AE_Macros.h"
-
- #include <math.h>
- #include "AEFX_FXwin.h"
- #include "AEFX_UILib.h"
-
- #define MAJOR_VERSION 1L
- #define MINOR_VERSION 1L
- #define BUG_VERSION 0
- #define STAGE_VERSION PF_Stage_RELEASE
- #define BUILD_VERSION 0
- #define NAME "FX Window UI"
- #define DESCRIPTION "⌐1996 Adobe Systems, Inc."
- #define ID 4055
-
-
- /** these are constants which identify the index of each parameter
- ** in the param block
- **/
-
- static PF_Err About (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_SPRINTF(out_data->return_msg,
- "FX UI sample, v%ld.%ld (c) 1996 Adobe Systems, Inc.",
- MAJOR_VERSION, MINOR_VERSION);
-
- return PF_Err_NONE;
- }
-
-
- static PF_Err GlobalSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
-
- out_data->my_version = PF_VERSION(MAJOR_VERSION, MINOR_VERSION,
- BUG_VERSION, STAGE_VERSION, BUILD_VERSION);
-
- out_data->out_flags = PF_OutFlag_CUSTOM_UI | PF_OutFlag_PIX_INDEPENDENT | PF_OutFlag_SEQUENCE_DATA_NEEDS_FLATTENING;
-
- return err;
- }
-
-
- static PF_Err GlobalSetdown (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
-
- return err;
- }
-
-
- #define UI_BOX_WIDTH 262
- #define UI_BOX_HEIGHT 102
-
- static PF_Err ParamsSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- PF_ParamDef def;
-
- AEFX_CLR_STRUCT(def)
-
- def.changed = 0;
- def.ui_flags = PF_PUI_CONTROL;
- def.ui_width = UI_BOX_WIDTH;
- def.ui_height = UI_BOX_HEIGHT;
- def.param_type = PF_Param_FIX_SLIDER;
- PF_ADD_NULL("Histogram");
-
- AEFX_CLR_STRUCT(def)
- PF_ADD_POPUP("Channel", EX_Channel_CHANS_PLUS - 1, EX_Channel_LUM, "Luminance|Red|Green|Blue|Alpha");
- PF_ADD_SLIDER("Black Point", 0, 255, 0, 255, 0);
- PF_ADD_SLIDER("White Point", 0, 255, 0, 255, 255);
- PF_ADD_SLIDER("Black Softness", 0, 255, 0, 255, 0);
- PF_ADD_SLIDER("White Softness", 0, 255, 0, 255, 0);
-
- def.flags = 0;
- def.param_type = PF_Param_CHECKBOX;
- def.u.bd.value = def.u.bd.dephault = FALSE;
- def.u.bd.u.nameptr = "";
- PF_STRCPY(def.name, "Invert" );
- if (err = PF_ADD_PARAM(in_data, -1, &def)) return err;
-
- out_data->num_params = EX_NUM_PARAMS;
-
- if (!err) {
- PF_CustomUIInfo ci;
-
- ci.events = PF_CustomEFlag_EFFECT;
-
- ci.comp_ui_width = ci.comp_ui_height = 0;
- ci.comp_ui_alignment = PF_UIAlignment_NONE;
-
- ci.layer_ui_width = ci.layer_ui_height = 0;
- ci.layer_ui_alignment = PF_UIAlignment_NONE;
-
- ci.preview_ui_width = ci.preview_ui_height = 0;
- ci.preview_ui_alignment = PF_UIAlignment_NONE;
-
- err = (*(in_data->inter.register_ui))(in_data->effect_ref, &ci);
- }
-
- return err;
- }
-
-
- static PF_Err SequenceSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- EX_Globals **globs;
- EX_Globals *globals;
-
- if (in_data->sequence_data) {
- DisposeHandle(in_data->sequence_data);
- out_data->sequence_data = NULL;
- }
-
- globs = (EX_Globals**)NewHandle(sizeof(EX_Globals));
-
- if (globs) {
- in_data->sequence_data = out_data->sequence_data = (Handle)globs;
- HLock((Handle)globs);
- globals = *globs;
- globals->freshHist = FALSE;
-
- SetRect(&globals->offRect,0,0,EX_HIST_WIDTH,EX_HIST_HEIGHT);
- if (!CreateOffscreenBitMap(&globals->graphbits, 1, &globals->offRect)) {
- err = memFullErr;
- }
-
- SetRect(&globals->wedgeRect,0,0,EX_HIST_WIDTH,EX_WEDGE_HEIGHT);
- if (!CreateOffscreenBitMap(&globals->wedgebits, 1, &globals->wedgeRect)) {
- err = memFullErr;
- }
-
- if (!err) globals->magic = EX_MAGIC;
-
- HUnlock((Handle)globs);
-
- } else {
- err = memFullErr;
- }
-
- if (err) {
- PF_SPRINTF(out_data->return_msg, "Not enough memory to execute"NAME);
- out_data->out_flags |= PF_OutFlag_DISPLAY_ERROR_MESSAGE;
- }
-
- return err;
-
- }
-
-
- PF_Err SequenceResetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- return (SequenceSetup(in_data, out_data, params, output));
- }
-
-
- static PF_Err SequenceSetdown (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- EX_Globals **globals;
-
- if (in_data->sequence_data) {
- globals = (EX_Globals**)in_data->sequence_data;
- DestroyOffscreenBitMap(DH(globals)->graphbits);
- DestroyOffscreenBitMap(DH(globals)->wedgebits);
- DH(globals)->graphbits = DH(globals)->wedgebits = NULL;
- DisposeHandle(in_data->sequence_data);
- out_data->sequence_data = NULL;
- }
- return err;
-
- }
-
-
- static PF_Err SequenceFlatten (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
-
- err = SequenceSetdown(in_data, out_data, params, output);
-
- return err;
- }
-
-
- /** FrameSetup (does the buffer resize)
- **/
-
- static PF_Err FrameSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- return err;
-
- }
-
- #define LOOP_PIXELS_START \
- for (y=0; y<output->height; y++) { \
- for (x=0; x<output->width; x++) {
-
-
- #define LOOP_PIXELS_END \
- ++src; ++dst; \
- } \
- src += s_skip; \
- dst += d_skip; \
- if ((y%32) == 0) { \
- err = PF_PROGRESS(in_data, y, output->height); \
- if (err) break; \
- } \
- \
- }
-
-
- static PF_Err Render (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- register PF_Pixel *src, *dst;
- register long x, y;
- long s_skip, d_skip;
- long *hist;
- EX_Globals **globals;
-
- PF_Err (*app)(PF_ProgPtr, long, ...) =
- ((PF_UtilCallbacks *)in_data->utils)->app;
-
- if (in_data->sequence_data == NULL) {
- err = SequenceSetup(in_data, out_data, params, output);
- }
-
- if (!err) {
-
- globals = (EX_Globals**)in_data->sequence_data;
- hist = DH(globals)->hist;
- s_skip = params[EX_INPUT]->u.ld.rowbytes/4 - params[EX_INPUT]->u.ld.width;
- d_skip = output->rowbytes/4 - output->width;
-
- src = params[EX_INPUT]->u.ld.data;
- dst = output->data;
-
- for (y=0; y<256; y++) {
- hist[y] = 0;
- }
-
- if (!err) {
- LOOP_PIXELS_START
- *dst = *src;
- hist[src->red] ++;
- LOOP_PIXELS_END
- }
- }
-
- if (!err) {
- DH(globals)->freshHist = TRUE;
- out_data->out_flags |= PF_OutFlag_REFRESH_UI;
-
- }
- else DH(globals)->freshHist = FALSE;
-
- return err;
- }
-
-
- PF_Err HandleEvent (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output,
- PF_EventExtra *event_extra );
-
-
- main (
- PF_Cmd cmd,
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output,
- void *extra )
- {
- PF_Err err = PF_Err_NONE;
- AEFX_DECLARE_A4
-
- AEFX_SET_A4
-
- switch (cmd) {
- case PF_Cmd_ABOUT:
- err = About(in_data,out_data,params,output);
- break;
- case PF_Cmd_GLOBAL_SETUP:
- err = GlobalSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_GLOBAL_SETDOWN:
- err = GlobalSetdown(in_data,out_data,params,output);
- break;
- case PF_Cmd_PARAMS_SETUP:
- err = ParamsSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_SEQUENCE_SETUP:
- err = SequenceSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_SEQUENCE_SETDOWN:
- err = SequenceSetdown(in_data,out_data,params,output);
- break;
- case PF_Cmd_SEQUENCE_RESETUP:
- err = SequenceResetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_SEQUENCE_FLATTEN:
- err = SequenceFlatten(in_data,out_data,params,output);
- break;
- case PF_Cmd_FRAME_SETUP:
- err = FrameSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_RENDER:
- err = Render(in_data,out_data,params,output);
- break;
- case PF_Cmd_EVENT:
- err = HandleEvent(in_data,out_data,params,output,extra);
- break;
- default:
- break;
- }
-
-
- AEFX_RESTORE_A4
- return err;
- }
-